package io.jft.doll.model.bindModel

import android.databinding.ObservableField
import com.g.base.ui.recyclerView.item.BaseItem
import io.jft.doll.R
import io.jft.doll.databinding.ItemTextTipSwitchBinding

/**
 * Created by G on 2017/8/21 0021.
 */
class TextTipSwitchBind(var text: String = "", tip: String = "", val showSwitch: Boolean = false, isChecked: Boolean = false, val hasMore: Boolean = false) : BaseItem<ItemTextTipSwitchBinding>() {
    override val layoutId: Int = R.layout.item_text_tip_switch
    val isChecked = ObservableField(isChecked)
    val tip = ObservableField(tip)

    override fun onBind(binding: ItemTextTipSwitchBinding) {
        if (!showSwitch) return
        binding.switchButton.isChecked = isChecked.get() == true
        binding.switchButton.setOnCheckedChangeListener { _, isChecked ->
            this.isChecked.set(isChecked)
        }
    }
}
